<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>business</title>
    <link rel="stylesheet" href="../../../static/layer/css/layui.css" media="all"/>
    <link rel="stylesheet" href="../../../static/css/font-awesome.min.css" media="all">
    <style>
        .layui-form-switch {
            width: 54px;
            margin-top: 0;
        }

        .layui-form-switch i {
            top: 2px;
        }
    </style>
</head>
<body>

<div class="layui-tab layui-tab-brief" lay-filter="expense_management">
    <ul class="layui-tab-title">
        <li class="layui-this">后台日志</li>
        <li data-2tab="1">前台日志</li>
    </ul>
    <div class="layui-tab-content" style="height: 100px;">
        <div class="layui-tab-item layui-show">
            <div style="padding: 10px; position: relative;">
                <div class="operateTable">
                    操作人：
                    <div class="layui-inline">
                        <input class="layui-input" name="OPERATOR" id="OPERATOR" placeholder="请输入关键字"
                               autocomplete="off">
                    </div>
                    操作时间：
                    <div class="layui-inline">
                        <input class="layui-input" name="OPERA_TIME" id="OPERA_TIME" placeholder="" autocomplete="off">
                    </div>
                    操作详情：
                    <div class="layui-inline">
                        <input class="layui-input" name="DETAILS" id="DETAILS" placeholder="请输入关键字" autocomplete="off">
                    </div>
                    <button class="layui-btn" data-type="reload">搜索</button>
                </div>
                <table class="layui-table"
                       lay-data="{height:'full-110', url:'/recordController/Systemlog/', page:true, limit:20, id:'roleTable'}"
                       lay-filter="role">
                    <thead>
                    <tr>
                        <!--<th lay-data="{checkbox:true, fixed: true}"></th>-->
                        <th lay-data="{field:'OPERATOR', width:250 ,align: 'center'} ">操作人</th>
                        <th lay-data="{field:'OPERA_TIME', width:250 ,align: 'center'}">操作时间</th>
                        <th lay-data="{field:'DETAILS', width:300 ,align: 'center'}">操作详情</th>
                        <th lay-data="{field:'IP', width:350 ,align: 'center'}">IP</th>
                    </tr>
                    </thead>
                </table>
                <script type="text/html" id="barDemo">
                    <a class="layui-btn layui-btn-mini" lay-event="edit">编辑</a>
                    <a class="layui-btn layui-btn-danger layui-btn-mini" lay-event="del">删除</a>
                </script>
            </div>
        </div>
        <div class="layui-tab-item">
            <div class="layui-tab-content" style="height: 100px;">
                <div class="layui-tab-item layui-show">
                    <div style=" position: relative;">
                        <div class="operateTable_t">
                            操作人：
                            <div class="layui-inline">
                                <input class="layui-input" name="OPERATOR_t" id="OPERATOR_t" placeholder="请输入关键字"
                                       autocomplete="off">
                            </div>
                            操作时间：
                            <div class="layui-inline">
                                <input class="layui-input" name="OPERA_TIME_t" id="OPERA_TIME_t" placeholder=""
                                       autocomplete="off">
                            </div>
                            操作详情：
                            <div class="layui-inline">
                                <input class="layui-input" name="DETAILS_t" id="DETAILS_t" placeholder="请输入关键字"
                                       autocomplete="off">
                            </div>
                            <button class="layui-btn" data-type="reloadt">搜索</button>
                        </div>
                        <table id="roleTable_t" lay-filter="RZF"></table>
                        <script type="text/html" id="RZbar">
                            <a class="layui-btn layui-btn-mini" lay-event="view">查看</a>
                        </script>
                    </div>
                </div>
                <div class="layui-tab-item">内容2</div>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript" src="../../../static/layer/layui.js"></script>
<script>
    var table;
    layui.use(['jquery', 'table', 'form', 'layer', 'laydate', 'element'], function () {
        table = layui.table;
        var form = layui.form;
        var $ = layui.jquery;
        var element = layui.element;
        var laydate = layui.laydate;

        laydate.render({
            elem: '#OPERA_TIME'
            , format: 'yyyy-MM-dd'
        });
        //监听主tab
        element.on('tab(expense_management)', function (data1) {
            tabselect = $(this).data("2tab");
            switch (tabselect){
                case 0:
                    break;
                case 1:
                    //加载进行中合同
                    table.render({
                        elem: '#roleTable_t'
                        , url: '/recordController/Systemlog_tb_record'
                        , cols: [[
                            {field: 'OPERATOR', event: 'setSign', title: '操作人', width: 250}
                            , {field: 'OPERA_TIME', event: 'setSign', title: '操作时间', width: 250}
                            , {field: 'DETAILS', event: 'setSign', title: '操作详情', width: 300}
                            , {fixed: 'right', width: 220, align: 'center', title: '操作', toolbar: '#RZbar'}

                        ]]
                        , id: 'roleTable_t'
                        , page: true
                        , height: 'full-100'
                        , limit: '10'
                    });
                    break;
            }
        });
        var active = {
            reload: function () {
                var OPERATOR = $('#OPERATOR').val();
                var OPERA_TIME = $('#OPERA_TIME').val();
                var DETAILS = $('#DETAILS').val();
                table.reload('roleTable', {
                    where: {
                        OPERATOR: OPERATOR,
                        OPERA_TIME: OPERA_TIME,
                        DETAILS: DETAILS
                    }
                });
            },
            reloadt: function () {
                var OPERATOR = $('#OPERATOR_t').val();
                var OPERA_TIME = $('#OPERA_TIME_t').val();
                var DETAILS = $('#DETAILS_t').val();
                table.reload('roleTable_t', {
                    where: {
                        OPERATOR: OPERATOR,
                        OPERA_TIME: OPERA_TIME,
                        DETAILS: DETAILS
                    }
                });
            },
            view: function () {
                alert(11)
                layer.open({
                    type: 2,
                    title: '新增角色',
                    shadeClose: false,
                    shade: [0.3],
                    maxmin: true, //开启最大化最小化按钮
                    area: ['900px', '90%'],
                    scrollbar: false, //屏蔽滚动条
                    content: 'operate.html?type=add'
                });
            }
        };

        $('.operateTable .layui-btn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        $('.operateTable_t .layui-btn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        //监听工具条
        table.on('tool(RZF)', function (obj) {
            var data = obj.data;
            console.log(data.CONTRACT_ID)
            if(!!data.CONTRACT_ID){
                parent.layer.open({
                    zIndex: 1000,
                    type: 2,    //弹出类型
                    title: '查看合同',   //标题
                    closeBtn: 1,    //显示关闭按钮
                    shade: [0.3],   //遮罩透明度
                    area: ['80%', '90%'],  //打开窗口的宽高
                    time: 0,    //几秒后自动关闭，默认0时不关闭
                    anim: 1,    //动画效果
                    resize: false,  //设置成不允许拉伸
                    content: '../../../webhtml/contract/loan_info.html?LOAN_ID=' + data.CONTRACT_ID + ''  //iframe的url
                });
            }
            if(!!data.BILL_ID){
                var hideShoukuan = "1";
                var nametype="金额"
                parent.layer.open({
                    zIndex: 1000,
                    type: 2,    //弹出类型
                    title: '查看账单',   //标题
                    closeBtn: 1,    //显示关闭按钮
                    shade: [0.3],   //遮罩透明度
                    area: ['80%', '90%'],  //打开窗口的宽高
                    time: 0,    //几秒后自动关闭，默认0时不关闭
                    anim: 1,    //动画效果
                    resize: false,  //设置成不允许拉伸
                    content: '../../../webhtml/contract/bill_check.html?hd=' + escape(hideShoukuan) + '&type=' + escape(nametype) + '&BILL_ID=' + data.BILL_ID + ''  //iframe的url
                });
            }
        });
        //监听工具条
        table.on('tool(role)', function (obj) {
            var data = obj.data;
            if (obj.event === 'detail') {
                layer.open({
                    type: 2,
                    title: data.ROLE_NAME,
                    shadeClose: false,
                    shade: [0.3],
                    maxmin: true, //开启最大化最小化按钮
                    area: ['900px', '90%'],
                    scrollbar: false, //屏蔽滚动条
                    content: 'operate.html?type=view&id=' + data.ID
                });
            } else if (obj.event === 'del') {
                layer.confirm('确认删除 ' + data.ROLE_NAME + ' 吗', {offset: '150px'}, function (index) {
                    layer.close(index);
                    $.ajax({
                        url: "/shsRole/edit",
                        data: {ID: data.ID, IS_DEL: 1},
                        dataType: "json",
                        type: "post",
                        async: false,
                        success: function (res) {
                            if (res.errcode === "0") {
                                reloadTable();
                                layer.msg(data.ROLE_NAME + " 已删除", {offset: '150px'});   // 弹出删除成功
                            } else if (res.errcode === "1") {
                                layer.msg(res.errmsg, function () {
                                });
                            }
                        },
                        error: function (XMLHttpRequest, textStatus, errorThrown) {
                            console.error(XMLHttpRequest.status);
                            console.error(XMLHttpRequest.readyState);
                            console.error(textStatus);
                        }
                    });
                });
            } else if (obj.event === 'edit') {
                layer.open({
                    type: 2,
                    title: "编辑 " + data.ROLE_NAME,
                    shadeClose: false,
                    shade: [0.3],
                    maxmin: true, //开启最大化最小化按钮
                    area: ['900px', '90%'],
                    scrollbar: false, //屏蔽滚动条
                    content: 'operate.html?type=edit&id=' + data.ID
                });
            }
        })
    });

    function reloadTable() {
        table.reload('roleTable', {});
    }
</script>
</body>
</html>